import { message } from 'antd';
import request from 'axios';

const baseURL = '请求地址';

request.defaults.baseURL = baseURL;
request.defaults.timeout = 3000;

request.interceptors.request.use(
  function (config) {
    return config;
  },
  function (error) {
    // 对请求错误做些什么
    return Promise.reject(error);
  },
);

// 请求返回拦截器
request.interceptors.response.use(
  (response) => {
    return response.data;
  },
  (error) => {
    message.error({ content: '出错了', key: 'error' });
    return Promise.reject(error);
  },
);

export default request;
